package com.ytxg.practice.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;


@Controller
public class IndexController {

    /**
     * 我的桌面模块
     * @param model
     * @param request
     * @return
     */
    @RequestMapping("/welcome")
    public String welcome(Model model, HttpServletRequest request){
        //获取服务器IP地址
        String localAddr = request.getLocalAddr();
        //获取服务器端口
        int localPort = request.getLocalPort();
        //获取服务器域名
        String localName = request.getLocalName();
        //获取服务器计算机名
        String serverName = request.getServerName();

        //下面的代码都是向前端传输获取到的数据
        model.addAttribute("serverName",serverName);
        model.addAttribute("localName",localName);
        model.addAttribute("localAddr",localAddr);
        model.addAttribute("localPort",localPort);
        model.addAttribute("osName","windows");
        model.addAttribute("javaVersion","java8");

        //传输完进入welcome页面
        return "admin/welcome";
    }
}
